package com.second.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.second.common.pojo.Course;
import com.second.common.pojo.Order;
import com.second.common.vo.Result;
import com.second.order.service.CourseService;
import com.second.order.service.OrderService;
import com.second.order.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @program: second
 * @description:
 * @author: 胡萌
 * @create: 2023-05-26 16:13
 **/
@RestController
@RequestMapping("/order")
@Api(tags = "订单接口类")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @Autowired
    private CourseService courseService;


    @ApiOperation("分页条件查询")
    @PostMapping("/findAllOrder/{current}/{pageSize}")
    public Result getAllOrder(
            @PathVariable Integer current,
            @PathVariable Integer pageSize,
            @RequestBody OrderVo orderVo
    ){
        Page<Order> orderPage = orderService.findByOrderPage(current, pageSize, orderVo);
        return Result.success(orderPage);
    }

    @ApiOperation("课程信息查询")
    @PostMapping("/queryAllCourse/{courseId}")
    public List<Course> queryAllCourse(@PathVariable String courseId){

        List<Course> byId = courseService.findById(courseId);

        return byId;
    }

    @ApiOperation("订单日志查询")
    @PostMapping("/queryOrderAndPayLog/{id}")
    public Result queryOrderAndPayLog(@PathVariable String id){

        Order orderAndPayLog = orderService.findOrderAndPayLog(id);

        return Result.success(orderAndPayLog);

    }

}
